<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 1.字符串
        let str="welcome";
        let [a,b,c,d,e,f,g]=str;
        console.log(a,b,c,d,e,f,g);
        let [...arr]=str;
        console.log(arr);

        // 2.数值等基本数据类型的解构
                // 等号右边的基本数据类型会自动转换为引用数据类型(对象)
                // 解构转换为对象中的原型方法
        let num=123;
        let num2=new Number(123);
        console.log(num2);
        let {toFixed}=num;
        console.log(toFixed);

        var obj={
            state:true,
            msg:"服饰",
            result:{
                type:"衣服",
                list:["裙子","鞋子","T恤","吊带"]
            }
        };

        function show(objs){//形参，将形参看成是一个对象
            if(objs.state){
                console.log("类型:"+objs.result.type);
                for(var i=0;i<objs.result.list.length;i++){
                    console.log(objs.result.list[i]);
                }
            }
        }
        show(obj);//实参

        function show2({state,result}){
            if(state){
                var {type,list}=result;
                console.log("类型是:"+type);
                for(var i=0;i<list.length;i++){
                    console.log(list[i]);
                }
            }
        }

        show2(obj);

        function show3({state,result:{type,list}}){
            if(state){
                console.log("类型是:"+type);
                for(var i=0;i<list.length;i++){
                    console.log(list[i]);
                }
            }
        }
        show3(obj);
    </script>
</head>
<body>
    
</body>
</html>